/*****************************************************************************
 * plum_hal_pwm.h
 *
 * Copyright (C) 2020 Jeasonvor 1101627719@qq.com
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 ****************************************************************************/
#ifndef __PLUM_HAL_PWM_H__
#define __PLUM_HAL_PWM_H__

/*****************************************************************************
 * Included Files
 ****************************************************************************/

/*****************************************************************************
 * Pre-processor Definitions
 ****************************************************************************/

/*****************************************************************************
 * Public Types
 ****************************************************************************/

typedef struct {
    plum_u32 gpio; /** GPIO引脚      */
    plum_u32 freq; /** PWM频率       */
    plum_u8  duty; /** PWM占空比     */
} plum_hal_pwm_cof_t;

/*****************************************************************************
 * Public Data
 ****************************************************************************/

/****************************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
/*****************************************************************************
 * Public Function Prototypes
 ****************************************************************************/

/**
 * @brief:  pwm功能初始化
 *
 * @param[in]:  id      -   PWM ID
 * @param[in]:  config  -   PWM配置指针
 *
 * @return： 返回执行状态
 */
plum_s32 plum_hal_pwm_init(plum_u32 id, plum_hal_pwm_cof_t *config);

/**
 * @brief:  PWM挂起
 *
 * @param[in]:  id      -   PWM ID
 *
 * @return:
 */
plum_void plum_hal_pwm_suspend(plum_u32 id);

/**
 * @brief:  PWM恢复
 *
 * @param[in]:  id      -   PWM ID
 *
 * @return:
 */
plum_void plum_hal_pwm_resume(plum_u32 id);

/**
 * @brief:  获取PWM当前占空比
 *
 * @param[in]:  id      -   PWM ID
 *
 * @return: 成功    -   返回占空比
 *          失败    -   返回错误码
 */
plum_s32 plum_hal_pwm_duty_get(plum_u32 id);

/**
 * @brief:  设置PWM当前占空比
 *
 * @param[in]:  id      -   PWM ID
 * @param[in]:  duty    -   占空比（0 ~ 100）
 *
 * @return: 返回错误码
 */
plum_s32 plum_hal_pwm_duty_set(plum_u32 id, plum_float duty);

/****************************************************************************/
#ifdef __cplusplus
}
#endif
/****************************************************************************/
#endif /* __PLUM_HAL_PWM_H__ */
/****************************************************************************/
/*                                                                          */
/*  End of file.                                                            */
/*                                                                          */
/****************************************************************************/
